<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>自由搜索</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <style>
        .wrapper {
            width: 350px;
            margin: 50px auto;
        }
        .t-c {
            text-align: center;
        }
        .icon {
            display: inline-block;
            width: 20px;
            height: 20px;
            vertical-align: middle;
        }
        .bai {
            background: url(baidu.png);
            background-size: 100%;
            background-position: -1px 0px;
            margin: -4px 1px 0 0;
        }
        .sou {
            background: url(sougou.png);
            background-size: 100%;
            background-position: -1px 1px;
            margin-right: 1px;
            overflow: hidden;
        }
        .bi {
            background: url(biying.png);
            background-size: 100%;
        }
        .b360 {
            background: url(360.png);
            background-size: 100%;
        }
    </style>
</head>
<body>
    <div class="wrapper">
        <fieldset class="layui-elem-field layui-field-title t-c" style="margin-top: 50px;">
            <legend>自由搜索</legend>
        </fieldset>
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li class="layui-this"><i class="icon bai"></i>百度</li>
                <li><i class="icon sou"></i>搜狗</li>
                <li><i class="icon bi"></i>必应</li>
                <li><i class="icon b360"></i>360</li>
            </ul>
            <div class="layui-tab-content" style="height: 100px;">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form layui-form-pane" onsubmit="return false">
                        <div class="layui-form-item">
                            <label class="layui-form-label">搜索词</label>
                            <div class="layui-input-block">
                                <input type="text" id="wordBai" name="title" autocomplete="off" placeholder="请输入搜索词" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item t-c">
                            <button type="submit" id="searchBai" class="layui-btn">百度搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" onsubmit="return false">
                        <div class="layui-form-item">
                            <label class="layui-form-label">搜索词</label>
                            <div class="layui-input-block">
                                <input type="text" id="wordSou" name="title" autocomplete="off" placeholder="请输入搜索词" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item t-c">
                            <button type="submit" id="searchSou" class="layui-btn">搜狗搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" onsubmit="return false">
                        <div class="layui-form-item">
                            <label class="layui-form-label">搜索词</label>
                            <div class="layui-input-block">
                                <input type="text" id="wordBi" name="title" autocomplete="off" placeholder="请输入搜索词" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item t-c">
                            <button type="submit" id="searchBi" class="layui-btn">必应搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form layui-form-pane" onsubmit="return false">
                        <div class="layui-form-item">
                            <label class="layui-form-label">搜索词</label>
                            <div class="layui-input-block">
                                <input type="text" id="word360" name="title" autocomplete="off" placeholder="请输入搜索词" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item t-c">
                            <button type="submit" id="search360" class="layui-btn">360搜索</button>
                        </div>
                    </form>
                </div>
            </div>
        </div> 
    </div>
    <script src="layui/layui.js"></script>
    <script>
        layui.use(['jquery','element'],function(){
            var $ = layui.jquery,
                element = layui.element();
            search('Bai');
            search('Sou');
            search('Bi');
            search('360');
            function search(type){
                $("#search"+type).click(function(){
                    var word = document.getElementById('word'+type);
                    var url = "";
                    if(type == 'Bai'){
                        url = "https://www.baidu.com/s?wd="+word.value;
                    }else if(type == 'Sou'){
                        url = "https://www.sogou.com/web?query="+word.value;
                    }else if(type =="Bi"){
                        url = "http://cn.bing.com/search?q="+word.value;
                    }else if(type == "360"){
                        url = "http://so.360.cn/s?q="+word.value;
                    }
                    window.open(url,"_blank");
                });
            };
        });
    </script>
</body>
</html>